Add a "group" property like the one found in radio buttons.
authorMatthias Clasen <mclasen@redhat.com>
Sun, 3 Apr 2005 07:11:09 +0000 (07:11 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sun, 3 Apr 2005 07:11:09 +0000 (07:11 +0000)
2005-04-03  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkradiomenuitem.c: Add a "group" property like
the one found in radio buttons.

* gtk/gtkradiobutton.c (gtk_radio_button_class_init): Fix
a typo in the docs.
(gtk_radio_button_set_group): Add change notification.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtkradiobutton.c
gtk/gtkradiomenuitem.c

index 2fa12bab6d2e9e1b9dfe5040298ea36911bdfdbc..0fbf5ef596449133df9a35922953eaf22267350b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-04-03  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkradiomenuitem.c: Add a "group" property like
+       the one found in radio buttons.
+
+       * gtk/gtkradiobutton.c (gtk_radio_button_class_init): Fix
+       a typo in the docs.
+       (gtk_radio_button_set_group): Add change notification.
+
 2005-04-01  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkselection.c: Move documentation inline, document
index 2fa12bab6d2e9e1b9dfe5040298ea36911bdfdbc..0fbf5ef596449133df9a35922953eaf22267350b 100644 (file)
@@ -1,3 +1,12 @@
+2005-04-03  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkradiomenuitem.c: Add a "group" property like
+       the one found in radio buttons.
+
+       * gtk/gtkradiobutton.c (gtk_radio_button_class_init): Fix
+       a typo in the docs.
+       (gtk_radio_button_set_group): Add change notification.
+
 2005-04-01  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkselection.c: Move documentation inline, document
index 2fa12bab6d2e9e1b9dfe5040298ea36911bdfdbc..0fbf5ef596449133df9a35922953eaf22267350b 100644 (file)
@@ -1,3 +1,12 @@
+2005-04-03  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtkradiomenuitem.c: Add a "group" property like
+       the one found in radio buttons.
+
+       * gtk/gtkradiobutton.c (gtk_radio_button_class_init): Fix
+       a typo in the docs.
+       (gtk_radio_button_set_group): Add change notification.
+
 2005-04-01  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkselection.c: Move documentation inline, document
index 4fc4df5ada6fd3670fb80528426b8e33f812f949..3d2d54c517a52b115150beb1197584b8df0f4568 100644 (file)
@@ -126,7 +126,7 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
   class->group_changed = NULL;
 
   /**
-   * GtkStyle::group-changed:
+   * GtkRadioButton::group-changed:
    * @style: the object which received the signal
    *
    * Emitted when the group of radio buttons that a radio button belongs
@@ -258,6 +258,7 @@ gtk_radio_button_set_group (GtkRadioButton *radio_button,
 
   g_object_ref (radio_button);
   
+  g_object_notify (G_OBJECT (radio_button), "group");
   g_signal_emit (radio_button, group_changed_signal, 0);
   if (old_group_singleton)
     {
index 9aef29f159c557da8bc55393793532808809a0df..4181e167df82fe10803a1fd7d7083b0df75d94e8 100644 (file)
 #include "gtkaccellabel.h"
 #include "gtkmarshalers.h"
 #include "gtkradiomenuitem.h"
+#include "gtkprivate.h"
+#include "gtkintl.h"
 #include "gtkalias.h"
 
 
+enum {
+  PROP_0,
+  PROP_GROUP
+};
+
+
 static void gtk_radio_menu_item_class_init     (GtkRadioMenuItemClass *klass);
 static void gtk_radio_menu_item_init           (GtkRadioMenuItem      *radio_menu_item);
 static void gtk_radio_menu_item_destroy        (GtkObject             *object);
 static void gtk_radio_menu_item_activate       (GtkMenuItem           *menu_item);
+static void gtk_radio_menu_item_set_property   (GObject               *object,
+                                               guint                  prop_id,
+                                               const GValue          *value,
+                                               GParamSpec            *pspec);
+static void gtk_radio_menu_item_get_property   (GObject               *object,
+                                               guint                  prop_id,
+                                               GValue                *value,
+                                               GParamSpec            *pspec);
 
 static GtkCheckMenuItemClass *parent_class = NULL;
 
@@ -80,6 +96,51 @@ gtk_radio_menu_item_new (GSList *group)
   return GTK_WIDGET (radio_menu_item);
 }
 
+static void
+gtk_radio_menu_item_set_property (GObject      *object,
+                                 guint         prop_id,
+                                 const GValue *value,
+                                 GParamSpec   *pspec)
+{
+  GtkRadioMenuItem *radio_menu_item;
+
+  radio_menu_item = GTK_RADIO_MENU_ITEM (object);
+
+  switch (prop_id)
+    {
+      GSList *slist;
+
+    case PROP_GROUP:
+      if (G_VALUE_HOLDS_OBJECT (value))
+       slist = gtk_radio_menu_item_get_group ((GtkRadioMenuItem*) g_value_get_object (value));
+      else
+       slist = NULL;
+      gtk_radio_menu_item_set_group (radio_menu_item, slist);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+gtk_radio_menu_item_get_property (GObject    *object,
+                                 guint       prop_id,
+                                 GValue     *value,
+                                 GParamSpec *pspec)
+{
+  GtkRadioMenuItem *radio_menu_item;
+
+  radio_menu_item = GTK_RADIO_MENU_ITEM (object);
+
+  switch (prop_id)
+    {
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
 void
 gtk_radio_menu_item_set_group (GtkRadioMenuItem *radio_menu_item,
                               GSList           *group)
@@ -136,6 +197,7 @@ gtk_radio_menu_item_set_group (GtkRadioMenuItem *radio_menu_item,
 
   g_object_ref (radio_menu_item);
 
+  g_object_notify (G_OBJECT (radio_menu_item), "group");
   g_signal_emit (radio_menu_item, group_changed_signal, 0);
   if (old_group_singleton)
     {
@@ -290,14 +352,27 @@ gtk_radio_menu_item_get_group (GtkRadioMenuItem *radio_menu_item)
 static void
 gtk_radio_menu_item_class_init (GtkRadioMenuItemClass *klass)
 {
+  GObjectClass *gobject_class;  
   GtkObjectClass *object_class;
   GtkMenuItemClass *menu_item_class;
 
-  object_class = (GtkObjectClass*) klass;
-  menu_item_class = (GtkMenuItemClass*) klass;
+  gobject_class = G_OBJECT_CLASS (klass);
+  object_class = GTK_OBJECT_CLASS (klass);
+  menu_item_class = GTK_MENU_ITEM_CLASS (klass);
 
   parent_class = g_type_class_peek_parent (klass);
 
+  gobject_class->set_property = gtk_radio_menu_item_set_property;
+  gobject_class->get_property = gtk_radio_menu_item_get_property;
+
+  g_object_class_install_property (gobject_class,
+                                  PROP_GROUP,
+                                  g_param_spec_object ("group",
+                                                       P_("Group"),
+                                                       P_("The radio menu item  whose group this widget belongs to."),
+                                                       GTK_TYPE_RADIO_MENU_ITEM,
+                                                       GTK_PARAM_WRITABLE));
+
   object_class->destroy = gtk_radio_menu_item_destroy;
 
   menu_item_class->activate = gtk_radio_menu_item_activate;